<script>
	import Music from './models/music.js'
	import lyrics from 'models/lyrics.js'
	import { MusicPlayer } from './utils/player.js'
	export default {
		onLaunch: function() {
			let vue = this;// vue.__proto__ 指向 Vue.prototype，即对象实例的__proto__指向其构造函数的原型
			uni.getSystemInfo({
				success: function(e) {
					// CustomBar为自定义标题栏高度
					vue.__proto__.ScreenHeight = e.screenHeight;
					// #ifndef MP
					vue.__proto__.StatusBar = e.statusBarHeight;
					if (e.platform == 'android') {
						vue.__proto__.CustomBar = e.statusBarHeight + 50;
					} else {
						vue.__proto__.CustomBar = e.statusBarHeight + 45;
					};
					// #endif
					// #ifdef MP-WEIXIN
					vue.__proto__.StatusBar = e.statusBarHeight;
					let custom = wx.getMenuButtonBoundingClientRect();
					vue.__proto__.Custom = custom;
					vue.__proto__.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
					// #endif		
					// #ifdef MP-ALIPAY
					vue.__proto__.StatusBar = e.statusBarHeight;
					vue.__proto__.CustomBar = e.statusBarHeight + e.titleBarHeight;
					// #endif
				}
			});
			vue.$store.commit('setMusic', new Music({
				title: '杏花弦外雨',
				url: 'https://kungfupan.gitee.io/vue-music/static/music/critty.mp3',
				author: 'qeqeqwewew',
				length: 237,
				progress: 0,
				lyrics
			}))
			// 注入播放器实例到全局
			vue.__proto__.MusicPlayer = new MusicPlayer({
				store: vue.$store,
				src: vue.$store.state.music.url,
				loop: true,
				volume: vue.$store.state.volume
			});
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style>
	/*每个页面公共css */
	@import url("icon.css");
	.flex-box{
		display: flex;
	}
	.flex-vbox{
		display: flex;
		flex-direction: column;
	}
	.flex-item{
		flex: 1;
	}
	.flex-valign{
		align-items: center;
	}
	.full-page{
		height: 100vh;
	}
	.page{
		height: 100%;
		font-size: 24rpx;
	}
	.link-btn{
		display: inline-block;
		padding: 10rpx 20rpx;
		border-radius: 46%;
	}
	.sub-title{
		font-size: 0.8em;
	}
</style>
